#!/usr/bin/env bash

echo '=====开始mvn clean====='
mvn clean

echo '=====开始mvn install&&package====='
mvn install -DskipTests=true && mvn package -DskipTests=true


echo '=====开始构建镜像====='

echo '=====开始构建 didiok-admin ====='
cd didiok-admin
mvn docker:build

cd ..

echo '=====开始构建 didiok-gateway ====='
cd didiok-gateway

mvn docker:build

cd ..
#
#echo '=====开始构建 didiok-community ====='
#cd didiok-community
#
#mvn docker:build
#
#cd ..

#echo '=====开始构建 didiok-file ====='
#cd didiok-file
#
#mvn docker:build
#
#cd ..

echo '=====开始构建 didiok-search ====='
cd didiok-search

mvn docker:build

cd ..

echo '=====开始构建 didiok-sms ====='
cd didiok-sms

mvn docker:build

cd ..

echo '=====开始构建 didiok-user ====='
cd didiok-user

mvn docker:build

cd ..

#echo '=====开始构建 didiok-rank ====='
#cd didiok-rank
#
#mvn docker:build
#
#cd ..

echo '=====开始构建 didiok-wechat ====='
cd didiok-wechat

mvn docker:build

cd ..
#
#echo '=====开始构建 didiok-pay ====='
#cd didiok-pay
#
#mvn docker:build
#
#cd ..

echo '=====镜像构建结束====='

echo '=====删除<none>镜像====='
if [[ -n $(docker images | grep "none" | awk '{print $3}') ]];then
    echo "------ 存在虚悬镜像，开始删除... ------"
    docker rmi $(docker images | grep "none" | awk '{print $3}')
else
    echo "------ 不存在虚悬镜像 ------"
fi